﻿using DevExpress.Utils.Win;
using DevExpress.XtraEditors.Popup;
using DevExpress.XtraGrid.Demos.util;
using DevExpress.XtraGrid.Editors;
using DevExpress.XtraLayout;
using DXApplicationTangche.DTO;
using DXApplicationTangche.UC.下单MTO.Service;
using DXApplicationTangche.UC.抖音出入库.Service;
using DXApplicationTangche.UC.订单一览新.订单预览新.model;
using mendian;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.抖音出入库
{
    public partial class Form抖音套号下单修改商品 : DevExpress.XtraEditors.XtraForm
    {
        public Boolean is确认 = false;
        private DouyinMTSOrderDTO douyinMTSOrderDTO;
        public 订单预览新Model model { get; set; }

        public Form抖音套号下单修改商品(DouyinMTSOrderDTO douyinMTSOrderDTO)
        {
            InitializeComponent();
            this.model = new 订单预览新Model(douyinMTSOrderDTO.refBarcode);
            this.douyinMTSOrderDTO = douyinMTSOrderDTO;
            this.label款号.Text = "当前款号：" + douyinMTSOrderDTO.styleNameCn;
            this.label面料号.Text = "当前面料号：" + douyinMTSOrderDTO.materialCode;

            //显示该款式的尺码组
            this.comboBox定制尺码.Items.Clear();
            List<String> 尺码 = new List<string>();
            尺码 = MTO订单Service.findSizeCdByStyleNameCn(douyinMTSOrderDTO.styleNameCn);
            foreach (String str in 尺码)
            {
                this.comboBox定制尺码.Items.Add(str);
            }
        }

        private void simpleButton确认_Click(object sender, EventArgs e)
        {
            //
            if (String.IsNullOrEmpty(this.textBox需求数量.Text))
            {
                MessageBox.Show("请补充数量");
                return;
            }
            try
            {
                this.model.尺寸 = FunctionHelper.JsonDeserialization<DTOStyleMeasureItems>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/style/generateStyleMeasureItemsByStyleNameCn?SIZE_CD="
                                    + this.model.OrderCommitDTO返回.styleSizeCd
                                    + "&styleNameCn=" + this.model.OrderCommitDTO返回.styleNameCn.Split()[0]
                                    + "&categoryId=" + this.model.build查询款式类别().styleCategoryDTO.id
                                )
                    );
                this.model
                    .buildDouyinStyleSizeCd(this.comboBox定制尺码.Text)
                    .buildSaleSampleOrderCommitDTO()
                    .buildDouyin(
                        this.textBox需求数量.Text.ToString(),
                        this.textBox抖音售价.Text.ToString()
                    );
                this.is确认 = true;
            }
            catch { }
            this.Close();
        }

    }
}
